"""
    @Author  ：思念 
    @File    ：5.自定义线程类.py
    @Date    ：2025/1/9 20:39 
"""
import requests
import threading

class MyThread(threading.Thread):

    def __init__(self, url):
        super().__init__()
        self.url = url

    # 定义线程执行体
    def run(self):
        response = requests.get(self.url).content
        filename = self.url.split('/')[-1]
        with open(filename, 'wb') as f:
            f.write(response)
            print(f'{self.url} 下载完成')


url_list = [
    'http://pic.bizhi360.com/bbpic/98/10798.jpg',
    'http://pic.bizhi360.com/bbpic/92/10792.jpg',
    'http://pic.bizhi360.com/bbpic/86/10386.jpg'
]

if __name__ == '__main__':
    for url in url_list:
        t = MyThread(url)
        t.start()